package indi.jp.project.business.yunying.controller;

import indi.jp.project.core.entity.JsonResult;
import indi.jp.project.core.util.SimpleEntityUtil;
import indi.jp.project.business.yunying.entity.ContractFiled;
import indi.jp.project.business.yunying.service.ContractFiledService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/yunying/contract")
public class ContractFiledController {

    @Resource
    private ContractFiledService contractFiledService;

    @GetMapping("/queryGrid")
    public JsonResult queryGrid(ContractFiled contractFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<ContractFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(contractFiled, request);
        return contractFiledService.queryGrid(contractFiled);
    }

    @GetMapping("/findById")
    public JsonResult findById(HttpServletRequest request) throws Exception {
        String taskId = request.getParameter("taskId");
        return contractFiledService.findById(taskId);
    }

    @PostMapping("/save")
    public JsonResult save(@RequestBody ContractFiled contractFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<ContractFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(contractFiled, request);
        return contractFiledService.save(contractFiled);
    }

    @PostMapping("/deleteById")
    public JsonResult deleteById(@RequestParam String id) throws Exception {
        return contractFiledService.deleteById(id);
    }

}
